#include <dbg.h>

#include <cassert>
#include <vector>

using namespace std;

class Solution {
public:
    int largestAltitude(vector<int>& gain) {
        vector<int> height{0};
        for (int i = 0; i < gain.size(); ++i) {
            height.push_back(gain[i] + height[i]);
        }

        return *max_element(height.begin(), height.end());
    }
};

int main() {
    Solution s;

    vector<int> gain1{-5, 1, 5, 0, -7};
    vector<int> gain2{-4, -3, -2, -1, 4, 3, 2};

    assert(s.largestAltitude(gain1) == 1);
    assert(s.largestAltitude(gain2) == 0);

    return 0;
}